package hn.cch.http.api;

import hn.cch.aspect.param.TestParam;
import hn.cch.constant.Letter;
import hn.cch.http.request.HttpReqMsg;
import hn.cch.http.response.LetterRespMsg;
import hn.cch.library.result.TestResult;
import hn.cch.util.JsonUtil;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * HTTP事件实现
 */
//singleton|prototype:单例或多例
@Scope("prototype")
@Component("/http/api/test|main")
public class HttpTest implements HttpApi {

    /**
     * 事件处理接口实现
     * @param
     * @return
     */
    @Override
    public byte[] api(HttpReqMsg httpReqMsg, byte[] bytes){
//        参数转化
//        格式：path|type
        String param = httpReqMsg.getGet().getPath() + "|" + httpReqMsg.getGet().getType();
        TestParam testParam = (TestParam) JsonUtil.toObject(bytes, TestParam.class);



        LetterRespMsg response = new LetterRespMsg();

        TestResult testResult = new TestResult("0","1","2","3","4","5","6","7","8","9");

        response.setCode(Letter.SUCCESS);
        response.setInfo("测试成功");
        response.setContent(testResult);




        return JsonUtil.toBytes(response);
    }



}
